package com.hnevc.kaoshitest1.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hnevc.kaoshitest1.R;

public class MyAdapter extends BaseAdapter {
    Context context;
    String[] titles;
    String[] timeArray;

    public MyAdapter(Context context, String[] titles, String[] timeArray) {
        this.context = context;
        this.titles = titles;
        this.timeArray = timeArray;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public Object getItem(int position) {
        return titles[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            convertView = View.inflate(context, R.layout.news_item_activity,null);
        }
        TextView titleTv = convertView.findViewById(R.id.news_title);
        TextView timeArrayTv = convertView.findViewById(R.id.news_time);
        titleTv.setText(titles[position]);
        timeArrayTv.setText(timeArray[position]);
        return convertView;
    }
}
